* do file for "non-unitary parties, government formation and gamson's law"

/* 

(1) The Farrell-McAllister index was computed as follows:
gen index_FM = .
label var index_FM "candidate-centeredness index, Farrell and McAllister"
replace index_FM = 10 if country=="Ireland"
replace index_FM = 7.1 if country=="Denmark"|country=="Finland"|country=="Italy"|country=="Luxembourg"
replace index_FM = 5.7 if country=="France V"
replace index_FM = 3.6 if country=="Germany"
replace index_FM = 2.9 if country=="Belgium"|country=="Netherlands"|country=="Sweden"|country=="Austria"
replace index_FM = 1.4 if country=="Iceland"|country=="Norway"|country=="Portugal"

(2) Random parties to remove were identified as follows: 
gen uu = runiform(0,1)
sort ngovparties caseno uu
gen dropp = 0
replace dropp = 1 if caseno!=caseno[_n-1]

*/

* data description
* number of cabinets
sort country caseno
count if caseno!=caseno[_n-1]
* number of governing parties
count if party_id!=.
* number in sample
count if dropp==0

* Government types
egen npivots = sum(pivot),by(caseno)
gen MWC = (majority_gov==1&(npivots==ngovparties))
gen oversized = (majority_gov==1&(npivots<ngovparties))
gen minority = (majority_gov==0)
gen str10 govtype = "minority"
replace govtype = "oversized" if oversized
replace govtype = "MWC" if MWC 
ta govtype if caseno!=caseno[_n-1]


eststo clear
* TABLE 1:  one obs from each coalition dropped at random, errors clustered by caseno
quietly regress portfolio_sh seat_sh if dropp==0,vce(cl caseno)
estimates store model1
quietly regress portfolio_sh seat_sh equal_sh if dropp==0,vce(cl caseno)
estimates store model2
quietly regress portfolio_sh seat_sh equal_sh partycent ps pe if dropp==0,vce(cl caseno)
estimates store model3
quietly regress portfolio_sh seat_sh equal_sh weight_sh if dropp==0,vce(cl caseno)
estimates store model5
esttab model1 model2 model3 model5,ar2 scalars(rmse) se

* TABLE 1, Model 4:  sample includes all parties in Warwick-Druckman dataset that appeared in government at least five times over the period 1945-1999 (pcount>=5).
* The requirement pcount>=5 often removes at least one party from each cabinet. In cases where this does not happen, the code removes one party from each cabinet. 
egen ng5=sum((pcount>=5)),by(caseno)
gen OK=(ng5<ngovparties)
regress portfolio_sh seat_sh equal_sh partycent ps pe i.pid if pcount>=5&(OK==1|(OK==0&dropp==0)),vce(cl caseno)


* appendix B: model with class fixed effects 
regress portfolio_sh seat_sh i.ngovparties if dropp==0,vce(cl caseno)
regress portfolio_sh i.ngovparties i.ngovparties#c.seat_sh if dropp==0,vce(cl caseno)

* lasso model selection
lasso linear portfolio_sh seat_sh equal_sh if dropp==0
* lassocoef,display(coef,standardized)
* lassoknots

* appendix C: using the Farrell-McAllister index_FM
regress portfolio_sh seat_sh equal_sh index_FM c.index_FM#c.seat_sh c.index_FM#c.equal_sh if dropp==0,vce(cl caseno)

* appendix D: Recoding the Netherlands 
gen pc2=partycentered
replace pc2=0 if country=="Netherlands"
gen ps2 = pc2*seat_sh
gen pe2 = pc2*equal_sh
regress portfolio_sh seat_sh equal_sh pc2 ps2 pe2 if dropp==0,vce(cl caseno)

* TABLE 2
regress ngovparties partycentered if caseno!=caseno[_n-1]
regress govpct partycentered if caseno!=caseno[_n-1]



